package com.iecampus.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.iecampus.activity.R;
import com.iecampus.activity.CategoryActivity.Category;

public class CategoryAdapter extends BaseAdapter {
	private List<Category> list;
	private Context context;

	public CategoryAdapter(List<Category> list, Context context) {
		this.list = list;
		this.context = context;
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder viewholder;
		if (convertView == null) {
			LayoutInflater inflater = LayoutInflater.from(context);
			convertView = inflater.inflate(R.layout.catagory_listitem, null);
			viewholder = new ViewHolder();
			viewholder.largeClass = (TextView) convertView
					.findViewById(R.id.large);
			viewholder.smallClass = (TextView) convertView
					.findViewById(R.id.small);
			convertView.setTag(viewholder);
		} else {
			viewholder = (ViewHolder) convertView.getTag();
		}
		viewholder.largeClass.setText(list.get(position).getLargeClass());
		viewholder.smallClass.setText(list.get(position).getSmallClass());
		return convertView;
	}

	class ViewHolder {
		private TextView largeClass;
		private TextView smallClass;
	}

}
